var myApp = angular.module('vaerditilbud', []);

myApp.controller('OrderController', function ($scope, $http) {
    $scope.customerResponsible = [];
    $scope.customerResponsible.initials = "q1zr";
    $scope.customerResponsible.displayName = "";
    $scope.updateCustomer = function() {
        $scope.customerResponsible.displayName = 'dane pobrane ' +  $scope.customerResponsible.initials;
    };
    $scope.customer = {"navn": "imie nazwisko","adress" : "jakis tam 123",
        kontaktList:[{type:'email',value:'mail@jakis.as'},{type:'telefon',value:'123123123'}]};
    $scope.customer.selected = true;
    $scope.customer.consent = true;
    $scope.customer.kontakt = $scope.customer.kontaktList[0];

    $scope.showModal = false;
    $scope.togglemodal = function () {
        $scope.showModal = !$scope.showModal;
    }
});


myApp.directive('modal', function() {
    return {
        restrict: 'E',
        scope: {
            show: '='
        },
        replace: true, // Replace with the template below
        transclude: true, // we want to insert custom content inside the directive
        link: function(scope, element, attrs) {
            scope.dialogStyle = {};
            if (attrs.width)
                scope.dialogStyle.width = attrs.width;
            if (attrs.height)
                scope.dialogStyle.height = attrs.height;
            scope.hideModal = function() {
                scope.show = false;
            };
        },
        templateUrl: "modal.html"
    };
});